package cn.wjdiankong.levideo.list.adapter;

import android.content.Context;
import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AbsListView;
import android.widget.ImageView;
import android.widget.TextView;
import cn.wjdiankong.levideo.R;

public class DouyinFragmentListAdapter extends BaseFragmentListAdapter{
	
	public DouyinFragmentListAdapter(Context mContext, AbsListView listView, boolean isLocal){
		super(mContext, listView, isLocal);
	}
	
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		View view = super.getView(position, convertView, parent);
		ViewHolder viewHolder = (ViewHolder) view.getTag();
		viewHolder.musicImg = (ImageView)view.findViewById(R.id.music_img);
		viewHolder.musicTxt = (TextView)view.findViewById(R.id.music_txt);
		viewHolder.musicLayout = view.findViewById(R.id.music_layout);
		view.setTag(viewHolder);
		
		viewHolder.textV.setText(dataList.get(position).filterTitleStr);
		if(TextUtils.isEmpty(dataList.get(position).filterUserNameStr)){
			viewHolder.userName.setText("昵称加载中...");
		}else{
			viewHolder.userName.setText(dataList.get(position).filterUserNameStr);
		}
		
		if(TextUtils.isEmpty(dataList.get(position).filterMusicNameStr)){
			viewHolder.musicLayout.setVisibility(View.GONE);
		}else{
			viewHolder.musicLayout.setVisibility(View.VISIBLE);
			viewHolder.musicTxt.setText(dataList.get(position).filterMusicNameStr);
		}
		if(!TextUtils.isEmpty(dataList.get(position).musicImgUrl)){
			imageLoader.displayImage(dataList.get(position).musicImgUrl, viewHolder.musicImg, userIconOptions);
		}
		return view;
		
	}

	@Override
	protected int getLayoutId() {
		return R.layout.fragment_douyin_adapter_item_layout;
	}

}
